package com.nextgenapp.fbgraph.fql
{
	import com.nextgenapp.fbgraph.GraphApi;
	import com.nextgenapp.fbgraph.common.GraphConst;
	
	/**
	 * give an fql query, give back the result.  
	 */
	public class GetFql
	{
		public static var apiUrl:String = GraphConst.PROTOCOL + "://api.facebook.com/method/fql.query?format=json&query={query}";
		
		public var access_token:String = null;
		
		private var callback:Function = null;
		
		public function GetFql(callback:Function=null)
		{
			this.callback = callback;
		}
		
		/**
		 * @param query - fql string
		 */
		public function getData(query:String):void {
			var url:String = apiUrl.replace("{query}", escape(query));
			var graphApi:GraphApi = new GraphApi();
			graphApi.access_token = this.access_token;
	        graphApi.read(url, callback);
		}
	}
}